﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MaHoaUngDung
{
    public partial class DangNhapFrm : DevComponents.DotNetBar.Office2007Form
    {
        public DangNhapFrm()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnSignin_Click(object sender, EventArgs e)
        {
            string email = tbEmail.Text.Trim();
            string pass = tbPassPhrase.Text.Trim();
            if (Program.ListUser.CheckUser(email, pass))
            {
                this.Visible = false;
                Program.CurrentUser = Program.ListUser.GetUserByEmail(email);
                HomeFrm mainForm = new HomeFrm();

                mainForm.ShowDialog(this);
                // if the main form has sign out, not exit the entire application
                if (!this.IsDisposed)
                {
                    this.Visible = true;
                }
            }
            else
            {
                MessageBox.Show("sai email hoặc mật khẩu", "đăng nhập thất bại",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }

        private void btnSignup_Click(object sender, EventArgs e)
        {
            DangKiFrm regForm = new DangKiFrm();
            this.Visible = false;
            regForm.ShowDialog(this);
            this.Visible = true;
        }
    }
}
